Skip to content

feat(subscription): support standalone Xray profiles - #739

Open
mustfqyl wants to merge 1 commit into
PasarGuard:devfrom
mustfqyl:feature/623-standalone-xray-profiles
Open

feat(subscription): support standalone Xray profiles#739
mustfqyl wants to merge 1 commit into
PasarGuard:devfrom
mustfqyl:feature/623-standalone-xray-profiles

Conversation

@mustfqyl

@mustfqyl mustfqyl commented Aug 2, 2026

Copy link
Copy Markdown

Summary

Adds standalone/client-only Xray profiles to subscription output without requiring a PasarGuard host, node, or server address.

  • Adds a new xray_standalone client template type.
  • Appends standalone profiles to Xray subscriptions as independent selectable configurations.
  • Preserves the complete custom Xray JSON without injecting a generated proxy outbound.
  • Supports custom local inbounds, freedom outbounds, DNS, FakeDNS, routing, fragment, and noise settings.
  • Supports subscription variables such as {USERNAME} inside nested profile values.
  • Adds a default Fragment / Serverless Bypass example.
  • Allows standalone templates to be created, edited, duplicated, and deleted without default/system-template restrictions.
  • Keeps standalone profile order deterministic.

Closes #623

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Refactor / cleanup
  • Documentation
  • Tests / CI

Checklist

  • I tested the change locally or explained why it cannot be tested.
  • I added or updated tests for behavior changes.
  • I updated documentation, translations, or examples if needed.
  • I checked database migrations when models or schema changed.
  • I did not include secrets, tokens, private keys, or unrelated changes.

Testing

  • uv run pytest -q tests/test_subscription_xray_standalone.py — 2 passed.
  • Ruff lint and formatting checks passed for the modified backend and test files.
  • TypeScript type checking completed successfully with tsc --noEmit.
  • API integration tests were added for template validation, deletion, and subscription output.
  • The API integration suite could not run in the local validation environment because its test admin/database fixture was not initialized; these tests are expected to run in CI.

No database migration is required. The existing client_templates.template_type column is string-backed and already supports additional template type values.

Screenshots

Not available in the current validation environment. The UI change adds Standalone Xray Profile as a new client-template type and provides an editable default JSON example.

Notes for reviewers

Every xray_standalone template is appended only to Xray subscription output. It is not associated with a host and does not receive a generated proxy outbound.

Standalone profiles are intentionally not marked as default or system templates because all standalone profiles are published independently and administrators must be able to delete the last one.

A standalone profile can provide local censorship-bypass behavior, but it does not change the user's public IP or provide server-side traffic accounting unless its custom JSON explicitly routes through a remote outbound.

Summary by CodeRabbit

  • New Features

    • Added support for standalone Xray client templates.
    • Standalone Xray profiles can be included in subscriptions, including when no host is configured.
    • Added a preconfigured standalone Xray template option in the dashboard.
    • Standalone profiles support variable substitution while preserving their outbound configuration.
  • Improvements

    • Standalone Xray templates require remarks and cannot be set as default.
    • Standalone templates can be deleted even when they are the only available template.
    • Template listings now use consistent ascending ID ordering.

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f2c7b251-b08e-4903-8809-b56e6e0a2090

📥 Commits

Reviewing files that changed from the base of the PR and between b52c4b6 and b4af4b9.

📒 Files selected for processing (13)
  • app/db/crud/client_template.py
  • app/models/client_template.py
  • app/operation/client_template.py
  • app/subscription/client_templates.py
  • app/subscription/share.py
  • app/subscription/xray.py
  • dashboard/src/features/templates/components/use-client-templates-list-columns.tsx
  • dashboard/src/features/templates/dialogs/client-template-modal.tsx
  • dashboard/src/features/templates/forms/client-template-form.ts
  • dashboard/src/service/api/index.ts
  • tests/api/test_client_template.py
  • tests/api/test_user.py
  • tests/test_subscription_xray_standalone.py

Walkthrough

Changes

Standalone Xray templates are now supported across backend CRUD operations, dashboard forms, cached subscription loading, and Xray profile rendering. They require valid JSON with non-empty remarks, cannot be defaults, and can be deleted as the only template. Subscription rendering appends complete profiles without proxy injection.

Standalone Xray profiles

Layer / File(s) Summary
Template type and lifecycle
app/models/client_template.py, app/db/crud/client_template.py, app/operation/client_template.py, dashboard/src/service/api/index.ts, dashboard/src/features/templates/..., tests/api/test_client_template.py
The xray_standalone type is added to backend and frontend contracts. Creation, modification, validation, default handling, deletion, ordering, and dashboard controls support standalone templates.
Standalone template loading and rendering
app/subscription/client_templates.py, app/subscription/share.py, app/subscription/xray.py, tests/test_subscription_xray_standalone.py
Xray subscriptions load cached standalone templates, substitute variables recursively, and append complete profiles without proxy injection.
Subscription integration coverage
tests/api/test_user.py
User subscription coverage verifies standalone rendering without a configured host, including remarks substitution and outbound preservation.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • PasarGuard/panel#286: Introduced related client-template CRUD, validation, caching, and Xray subscription functionality.

Suggested labels: enhancement, Backend, Frontend

Suggested reviewers: immohammad20000, x0sina

Poem

A rabbit adds a profile bright,
With local routes and TLS light.
No proxy sneaks into the flow,
Variables bloom where values go.
Standalone Xray hops just right.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the primary change: support for standalone Xray profiles in subscriptions.
Linked Issues check ✅ Passed The changes add selectable standalone Xray profiles without hosts, avoid proxy injection, and support complete custom Xray JSON as required by issue #623.
Out of Scope Changes check ✅ Passed The changes remain focused on standalone Xray templates, subscription rendering, validation, UI support, and related tests.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Warning

⚠️ This pull request shows signs of AI-generated slop (phantom_api). It has been flagged by CodeRabbit slop detection and should be reviewed carefully.

@ImMohammad20000

ImMohammad20000 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

what is the use for this?

@mustfqyl

mustfqyl commented Aug 3, 2026

Copy link
Copy Markdown
Author

what is the use for this?

This is useful for publishing client-side-only Xray configurations through the subscription system without requiring a PasarGuard node or host.

For example, an administrator can add a standalone Fragment, DNS, routing, FakeDNS, noise, or censorship-bypass profile. It will appear as a separate selectable configuration in supported Xray clients.

The main use case is when the configuration performs its logic locally on the user's device and therefore does not need a generated proxy outbound or server address.

It does not replace normal PasarGuard proxy profiles and does not provide IP changing or traffic accounting by itself. It only allows complete custom Xray JSON profiles to be distributed and updated through the existing subscription URL.

@ImMohammad20000

Copy link
Copy Markdown
Contributor

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot added Backend enhancement New feature or request Frontend labels Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants